package com.ruoyi.pms.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.pms.domain.DetailText;
import com.ruoyi.pms.service.IDetailTextService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 富文本测试Controller
 * 
 * @author yf
 * @date 2022-02-09
 */
@RestController
@RequestMapping("/text1")
public class DetailTextController extends BaseController
{
    @Autowired
    private IDetailTextService detailTextService;

    /**
     * 查询富文本测试列表
     */
    @RequiresPermissions("pms:text1:list")
    @GetMapping("/list")
    public TableDataInfo list(DetailText detailText)
    {
        startPage();
        List<DetailText> list = detailTextService.selectDetailTextList(detailText);
        return getDataTable(list);
    }

    /**
     * 导出富文本测试列表
     */
    @RequiresPermissions("pms:text1:export")
    @Log(title = "富文本测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DetailText detailText)
    {
        List<DetailText> list = detailTextService.selectDetailTextList(detailText);
        ExcelUtil<DetailText> util = new ExcelUtil<DetailText>(DetailText.class);
        util.exportExcel(response, list, "富文本测试数据");
    }

    /**
     * 获取富文本测试详细信息
     */
    @RequiresPermissions("pms:text1:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(detailTextService.selectDetailTextById(id));
    }

    /**
     * 新增富文本测试
     */
    @RequiresPermissions("pms:text1:add")
    @Log(title = "富文本测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DetailText detailText)
    {
        System.out.println("detail====================="+detailText.getDetail());
        return toAjax(detailTextService.insertDetailText(detailText));
    }

    /**
     * 修改富文本测试
     */
    @RequiresPermissions("pms:text1:edit")
    @Log(title = "富文本测试", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DetailText detailText)
    {
        return toAjax(detailTextService.updateDetailText(detailText));
    }

    /**
     * 删除富文本测试
     */
    @RequiresPermissions("pms:text1:remove")
    @Log(title = "富文本测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(detailTextService.deleteDetailTextByIds(ids));
    }
}
